package com.mingshine.cloud.test;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
/**
 * 消息发布者 直连路由键
 * @Class FirstDirectSender
 * @Author 作者姓名:LiuXing
 * @Version 1.0
 * @Date 创建时间：2019-05-20 17:09
 * @Direction 类说明
 */
//@Component
public class FirstDirectSender {
 
    @Autowired
    private RabbitTemplate rabbitTemplate;
 
    /**
     * 发送消息
     * @param uuid
     * @param message  消息
     */
    public void send(String uuid,Object message) {
        CorrelationData correlationId = new CorrelationData(uuid);
        /**
         * ExchangeConfig.DIRECT_EXCHANGE  指定消息交换机
         * RabbitMqConfig.ROUTIN_DIRECT_KEY  指定路由键
         */
        //发送消息至：direct类型的交互机【RabbitMqConfig.DIRECT_EXCHANGE】上，路由键是【RabbitMqConfig.ROUTIN_DIRECT_KEY】
        rabbitTemplate.convertAndSend( ExchangeConfig.DIRECT_EXCHANGE , RabbitMqConfig.ROUTIN_DIRECT_KEY ,
                message, correlationId);
    }
 
}